public class Test {
    public static void main(String[] args) {
        int[] arr = {3,5,7,1,2,9,6};
        boolean flg = false;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length-i-1; j++) {
                if (arr[j] > arr[j+1]) {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                    flg = true;
                }
            }
            if (flg) break;
        }
        for(int i : arr) {
            System.out.println(i);
        }
    }
}
